﻿//const sqlite3 = require('sqlite3').verbose();
const sql = require('sql');
const tables = {

     checked: sql.define({
          name: 'checked',
          columns: [{
              name: 'id',
              dataType: ' integer',
              primaryKey: true,
            }, 
            {
              name: 'check',
              dataType: 'varchar(4096)'
            },
            {
              name: 'list',
              dataType: 'varchar(4096)'
            },
          ]
    }),
  // 数据库配置
    record: sql.define({
          name: 'record',
          columns: [{
              name: 'id',
              dataType: ' integer',
              primaryKey: true,
            }, {
              name: 'type',
              dataType: 'varchar(256)'
            }, {
              name: 'data',
              dataType: 'varchar(4096)'
            }, {
              name: 'time',
              dataType: 'TIMESTAMP default CURRENT_TIMESTAMP'
            }
          ]
    }),   
    kv: sql.define({
          name: 'kv',
          columns: [{
              name: 'key',
              dataType: ' varchar(256)',
              primaryKey: true,
            }
            , {
              name: 'value',
              dataType: 'varchar(4096)'
            }, {
              name: 'time',
              dataType: 'TIMESTAMP default CURRENT_TIMESTAMP'
            }
          ]
    }),
    setup: sql.define({
          name: 'setup',
          columns: [ 
            {
              name: 'room',
              dataType: 'varchar(256)',
              unique: true
            },{
              name: 'area',
              dataType: 'varchar(256)',
              unique: true
            }, {
              name: 'data',
              dataType: 'varchar(4096)'
            }
          ]
        }),
    pinyin:sql.define({
        name: 'pinyin',
        columns: [ 
            {
                name: 'abbr',
                dataType: 'varchar(16)',
            }, 
            {
                name: 'target_id',
                dataType: 'integer',
            }, 
            {
                name: 'doc_name',
                dataType: 'string',
            }, 
            {
                name: 'sn',
                dataType: 'string',
            }, 
            {
                name: 'area',
                dataType: 'integer',
            }, 
            {
                name: 'column',
                dataType: 'integer',
            }, 
            {
                name: 'layer',
                dataType: 'integer',
            },
            {
                name: 'section',
                dataType: 'integer',
            },


        ]
    }),
    archives:sql.define({
        name: 'sys_Archives',
        columns: ['ID','SN','docName', 'Area', 'Column', 'Layer', 'Section']
    }),



}

module.exports = tables